<%@ page import="com.bjpowernode.javaweb.jsp.bean.Student" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@page contentType="text/html;charset=utf-8" %>
<%--引入核心标签库--%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%--专门负责格式化--%>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%--sql的标签库--%>
<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>

<%
    List<Student> stuList=new ArrayList<>();
    Student s1=new Student("110","进场");
    Student s2=new Student("120","救护车");
    Student s3=new Student("130","消防车");

    stuList.add(s1);
    stuList.add(s2);
    stuList.add(s3);

    request.setAttribute("stuList",stuList);
%>
<%--将list集合中元素遍历，输出学生信息到浏览器--%>
<%
    List<Student> stus=(List<Student>)request.getAttribute("stuList");

    for(Student student:stus){

%>
    id:<%=student.getId()%>,name:<%=student.getName()%><br/>
<%
    }
%>

<%--使用核心库的foreach--%>
<%--items="要迭代的集合" var="迭代的每一项"--%>
<c:forEach items="${stuList}" var="stu">
    id:${stu.id},name:${stu.name}<br/>
</c:forEach>